package com.youdelu.stock.dao.actions.QuoteList.task;

import com.youdelu.stock.common.util.CommonUtils;
import com.youdelu.stock.dao.actions.QuoteList.QuListAction;
import com.youdelu.stock.dao.actions.QuoteList.requestParam.QuListParam;
import com.youdelu.stock.dao.actions.QuoteList.respone.Data;
import com.youdelu.stock.bean.GpData;
import com.youdelu.stock.dao.actions.QuoteList.respone.QuListRespone;

import java.util.ArrayList;
import java.util.List;

/**
* ${remark} 任务
* Created by youdelu on 2022-03-08 14:03:22.
*/
public class QuListTask{
    /**
     * 加载全部分页数据
     */
    private int pageSize = 100;
    private int pageIndex = 1;
    private int allPage = 0;
    private void getNextWidthAll(){
        QuListParam quListParam = new QuListParam();
        quListParam.setMarket("CN");//CN,
        quListParam.setSize(pageSize+"");//30,
        quListParam.setOrderby("percent");//percent,
        quListParam.setOrder_by("percent");//percent,
        quListParam.setPage(pageIndex+"");//2,
        quListParam.setType("sh_sz");//sh_sz,
        quListParam.setOrder("desc");//desc,
        QuListAction action= new QuListAction();

        QuListRespone respone = action.get(quListParam);
        Data data = respone.getData();
        //保存全部
        gpDataList.addAll(data.getList());
        allPage = CommonUtils.getAllPage(data.getCount(),pageSize);
        pageIndex++;
        if(pageIndex<allPage){
            getNextWidthAll();
        }
    }
    private List<GpData> gpDataList;
    public List<GpData> getGpData(){
        gpDataList = new ArrayList<>();
        getNextWidthAll();
        return gpDataList;
    }
}